//
//  FKChooseAttrItemCell.m
//  BaiYeMallShop
//
//  Created by Macbook Pro on 2018/12/5.
//  Copyright © 2018 Macbook Pro. All rights reserved.
//

#import "FKChooseAttrItemCell.h"

@interface FKChooseAttrItemCell ()

@property(nonatomic, weak) UIButton *textBtn;

@end

@implementation FKChooseAttrItemCell

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self setupSubviews];
    }
    return self;
}

- (void)setupSubviews
{
    UIButton *textBtn = [UIButton fk_btnWithFont:fk_adjustFont(14) titleColor:fkColor333333 selectedTitleColor:[UIColor whiteColor]];
    [self.contentView addSubview:textBtn];
    self.textBtn = textBtn;
    [textBtn setBackgroundImage:[UIImage fk_imageWithColor:fkBgColor] forState:UIControlStateNormal];
    [textBtn setBackgroundImage:[UIImage fk_imageWithColor:fkMainColor] forState:UIControlStateSelected];
    textBtn.layer.cornerRadius = 15;
    textBtn.clipsToBounds = true;
    textBtn.userInteractionEnabled = false;
    [textBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
}


#pragma mark - setter
- (void)setModel:(FKGoodsSpecificationValue *)model
{
    _model = model;
    
    [self.textBtn setTitle:model.title forState:UIControlStateNormal];
    self.textBtn.layer.cornerRadius = model.itemSize.height * 0.5;
    self.textBtn.selected = model.isSelected;
}

//- (void)setSelected:(BOOL)selected
//{
//    [super setSelected:selected];
//    
//    self.textBtn.selected = selected;
//}

@end
